Troubleshooting

Q. I get a NullReferenceException when showing the grid.

A. This typically indicates that you are running under .NET Framework 3.0 RTM. The WPF Property Grid requires .NET Framework 3.0 SP1 or above. The installer checks for the presence of SP1 on development machines, but you may see this exception if an application which uses the grid is run on a machine without SP1.

Q. When I edit a boolean or enum property I get a StackOverflowException.

A. This occurs because the change to the value is being endlessly echoed back and forth between the editor and the property. The usual cause is that the data object is raising the INotifyPropertyChanged.PropertyChanged event whenever the property is set, even if the value has not changed.

Modify your data object to raise PropertyChanged only if the new value is different from the old one.

Boolean and enum types are most likely to encounter this because the ComboBox control (the default editor for these types) tries to update its source whenever its selection changes, even if the actual value of the ComboBox control has not changed.

Q. When I host the PropertyGrid control in a Windows Form, I don’t see the property names.

A. Windows Forms does not correctly measure the property name column during the form constructor. The column is incorrectly given a width so narrow as to prevent any text being displayed.

Modify your Windows Forms code to set the SelectedObject or ItemsSource property in the Load event handler rather than in the constructor.

Q. My custom property editors don’t appear when I use the ItemsSource property.

A. Check that the property editor declaration does not include a DeclaringType. A DeclaringType means that the editor will be used only if the entry is a member property of that type. This is usually appropriate when editing objects, because it ensures that the editor is not inadvertently used for a property of the same name but different semantics, but it is not appropriate when binding to a collection because the elements are not member properties of a type.

Q. When I create multiple instances of the grid (or of an editor), the first one appears, but the others do not.

A. This may occur when you use inline resources to style or template the grid or editor. Move these resources into a Resources section, for example at Window or Application level.